import React, { useEffect } from 'react'
import { Form, Input } from "antd";
import { useSelector, useDispatch } from "umi"
import DropPopover from '@/components/DropPopover';
export default function index({ reload }) {
    const { isClearForm } = useSelector(state => state.common)
    const [form] = Form.useForm();
    const dispatch = useDispatch();
    // 判断处理
    useEffect(() => {
        if (isClearForm) {
            form.resetFields();
            reload({});
            dispatch({
                type: "common/setIsClearForm",
                payload: false
            })
        }
    }, [isClearForm])
    return (
        <Form layout='vertical' form={form}>
            <Form.Item name="staffNameVal" label="搜索员工">
                <Input
                    placeholder='请输入搜索的员工'
                    readOnly
                    addonAfter={<DropPopover searchType="userName" getnewValue={(item) => {
                        console.log(item)
                        form.setFieldsValue({
                            staffNameVal: item.userName,
                        });
                        reload({
                            staffName: item._id
                        })
                    }} interfaced={"getStaffLists"}
                        placeValue="员工姓名"></DropPopover>}>
                </Input>
            </Form.Item>
        </Form>
    )
}
